﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    x:Class="BaseTypesLib.Resources.BaseFieldsRS"
                    xmlns:m="clr-namespace:BaseTypesLib.Model"
                    xmlns:ms="clr-namespace:BaseTypesLib.Model;assembly=BBInterfaceNET.FieldInfrastructure"
                    xmlns:conv="clr-namespace:BaseTypesLib.Converters;assembly=BBInterfaceNET.FieldInfrastructure"
                    xmlns:ctrls="clr-namespace:BaseTypesControlLib.Controls;assembly=BaseTypesControlLib"
                    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                    >
    <conv:HorizontalAlignmentConverter x:Key="hconv"/>
    <conv:VerticalAlignmentConverter x:Key="vconv"/>
    
    <SolidColorBrush x:Key="fieldBrush" Color="GreenYellow" Opacity="0.5"/>
    <SolidColorBrush x:Key="managerBrush" Color="LightBlue" Opacity="0.5"/>
    
    <conv:FontStyleConverter x:Key="styleConv"/>
    <conv:FontWeightConverter x:Key="weightConv"/>
    <conv:FontSizeConverter x:Key="sizeConv"/>

    <conv:BackgroundToBrushConverter x:Key="bgConv"/>
<!--field styles-->
    <DataTemplate DataType="{x:Type m:CustomListField}">
        <Border MinWidth="3" MinHeight="3" Background="{Binding Background, Converter={StaticResource bgConv}}"
                x:Name="border" BorderBrush="SteelBlue"
                HorizontalAlignment="{Binding Path=HorizontalAlignment, Converter={StaticResource hconv}}"
                VerticalAlignment="{Binding Path=VerticalAlignment, Converter={StaticResource vconv}}"
                Margin="{Binding Margin}"
                TextBlock.FontSize="{Binding Path=Font, Converter={StaticResource sizeConv}}"
              TextBlock.FontStyle="{Binding Path=Font.Style, Converter={StaticResource styleConv}}"
              TextBlock.FontWeight="{Binding Path=Font.Style, Converter={StaticResource weightConv}}"
                >
            <ctrls:CustomListFieldControl ListItemType="{Binding ItemType}" 
                                        Background="Transparent" />
        </Border>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
    
    <DataTemplate DataType="{x:Type m:DateField}">
        <Border MinWidth="3" MinHeight="3" Background="{Binding Background, Converter={StaticResource bgConv}}"
                x:Name="border" BorderBrush="SteelBlue"
                HorizontalAlignment="{Binding Path=HorizontalAlignment, Converter={StaticResource hconv}}"
                VerticalAlignment="{Binding Path=VerticalAlignment, Converter={StaticResource vconv}}"
                Margin="{Binding Margin}"
                TextBlock.FontSize="{Binding Path=Font, Converter={StaticResource sizeConv}}"
              TextBlock.FontStyle="{Binding Path=Font.Style, Converter={StaticResource styleConv}}"
              TextBlock.FontWeight="{Binding Path=Font.Style, Converter={StaticResource weightConv}}"
                >
            <ctrls:DateFieldControl Label="{Binding Label}" Date="{Binding Date}" Mode="{Binding Mode}"
                                    TimeFormat="{Binding TimeFormat}" DateFormat="{Binding DateFormat}"
                                        Background="Transparent"
                                        />
        </Border>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
    
    <DataTemplate DataType="{x:Type m:NumericChoiceField}">
        <Border MinWidth="3" MinHeight="3" Background="{Binding Background, Converter={StaticResource bgConv}}"
                x:Name="border" BorderBrush="SteelBlue"
                HorizontalAlignment="{Binding Path=HorizontalAlignment, Converter={StaticResource hconv}}"
                VerticalAlignment="{Binding Path=VerticalAlignment, Converter={StaticResource vconv}}"
                Margin="{Binding Margin}"
                TextBlock.FontSize="{Binding Path=Font, Converter={StaticResource sizeConv}}"
              TextBlock.FontStyle="{Binding Path=Font.Style, Converter={StaticResource styleConv}}"
              TextBlock.FontWeight="{Binding Path=Font.Style, Converter={StaticResource weightConv}}"
                >
            <ctrls:NumericChoiceControl Label="{Binding Label}" SelectedIndex="{Binding SelectedIndex}"
                                        Start="{Binding Start}" End="{Binding End}" Increment="{Binding Increment}"
                                        Background="Transparent"
                                        />
        </Border>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
    
    <DataTemplate DataType="{x:Type m:ObjectChoiceField}">
        <Border MinWidth="3" MinHeight="3" Background="{Binding Background, Converter={StaticResource bgConv}}"
                x:Name="border" BorderBrush="SteelBlue"
                HorizontalAlignment="{Binding Path=HorizontalAlignment, Converter={StaticResource hconv}}"
                VerticalAlignment="{Binding Path=VerticalAlignment, Converter={StaticResource vconv}}"
                Margin="{Binding Margin}"
                TextBlock.FontSize="{Binding Path=Font, Converter={StaticResource sizeConv}}"
              TextBlock.FontStyle="{Binding Path=Font.Style, Converter={StaticResource styleConv}}"
              TextBlock.FontWeight="{Binding Path=Font.Style, Converter={StaticResource weightConv}}"
                >
            <ctrls:ObjectChoiceControl Label="{Binding Label}" SelectedIndex="{Binding SelectedIndex}"
                                        Choices="{Binding Choices}" Background="Transparent"
                                        />
        </Border>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
    
    <DataTemplate DataType="{x:Type m:SeparatorField}">
        <Border MinWidth="3" MinHeight="3" Background="{Binding Background, Converter={StaticResource bgConv}}"
                x:Name="border" BorderBrush="SteelBlue"
                HorizontalAlignment="{Binding Path=HorizontalAlignment, Converter={StaticResource hconv}}"
                VerticalAlignment="{Binding Path=VerticalAlignment, Converter={StaticResource vconv}}"
                Margin="{Binding Margin}"
                TextBlock.FontSize="{Binding Path=Font, Converter={StaticResource sizeConv}}"
              TextBlock.FontStyle="{Binding Path=Font.Style, Converter={StaticResource styleConv}}"
              TextBlock.FontWeight="{Binding Path=Font.Style, Converter={StaticResource weightConv}}"
                >
            <ctrls:SeparatorFieldControl IsHorizontal="{Binding IsHorizontal}"
                                         Background="Transparent"/>
        </Border>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate DataType="{x:Type m:LabelField}">
        <Grid HorizontalAlignment="{Binding Path=HorizontalAlignment, Converter={StaticResource hconv}}"
              VerticalAlignment="{Binding Path=VerticalAlignment, Converter={StaticResource vconv}}"
              Background="{Binding Background, Converter={StaticResource bgConv}}"
              MinWidth="3" MinHeight="3"
              Margin="{Binding Margin}"
              TextBlock.FontSize="{Binding Path=Font, Converter={StaticResource sizeConv}}"
              TextBlock.FontStyle="{Binding Path=Font.Style, Converter={StaticResource styleConv}}"
              TextBlock.FontWeight="{Binding Path=Font.Style, Converter={StaticResource weightConv}}"
              >
            <ctrls:LabelFieldControl Text="{Binding Text}"  BorderBrush="SteelBlue" x:Name="border"
                                     UseAllWidth="{Binding UseAllWidth}"
                                     Background="Transparent"
                                     />
        </Grid>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate DataType="{x:Type m:ButtonField}">
        <Border HorizontalAlignment="{Binding Path=HorizontalAlignment, Converter={StaticResource hconv}}"
              VerticalAlignment="{Binding Path=VerticalAlignment, Converter={StaticResource vconv}}"
              Background="Transparent" MinWidth="3" MinHeight="3"
              BorderBrush="SteelBlue" x:Name="border" Margin="{Binding Margin}"
                TextBlock.FontSize="{Binding Path=Font, Converter={StaticResource sizeConv}}"
              TextBlock.FontStyle="{Binding Path=Font.Style, Converter={StaticResource styleConv}}"
              TextBlock.FontWeight="{Binding Path=Font.Style, Converter={StaticResource weightConv}}"
              >
            <ctrls:ButtonFieldControl Label="{Binding Label}" Editable="{Binding Editable}"
                                      Focusable="{Binding Focusable}" ReadOnly="{Binding ReadOnly}"
                                      Background="{Binding Background, Converter={StaticResource bgConv}}"
                                      />
        </Border>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate DataType="{x:Type m:EditField}">
        <Grid HorizontalAlignment="{Binding Path=HorizontalAlignment, Converter={StaticResource hconv}}"
              VerticalAlignment="{Binding Path=VerticalAlignment, Converter={StaticResource vconv}}"
              Background="{Binding Background, Converter={StaticResource bgConv}}" MinWidth="3" MinHeight="3"
              Margin="{Binding Margin}"
              TextBlock.FontSize="{Binding Path=Font, Converter={StaticResource sizeConv}}"
              TextBlock.FontStyle="{Binding Path=Font.Style, Converter={StaticResource styleConv}}"
              TextBlock.FontWeight="{Binding Path=Font.Style, Converter={StaticResource weightConv}}"
              >
            <ctrls:EditFieldControl Label="{Binding Label}" Text="{Binding Text}" 
                        BorderBrush="SteelBlue" x:Name="border"
                        Background="Transparent" />
        </Grid>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate DataType="{x:Type m:CheckboxField}">
        <Border HorizontalAlignment="{Binding Path=HorizontalAlignment, Converter={StaticResource hconv}}"
              VerticalAlignment="{Binding Path=VerticalAlignment, Converter={StaticResource vconv}}"
              Background="{Binding Background, Converter={StaticResource bgConv}}" MinWidth="3" MinHeight="3"
                Margin="{Binding Margin}"
                TextBlock.FontSize="{Binding Path=Font, Converter={StaticResource sizeConv}}"
              TextBlock.FontStyle="{Binding Path=Font.Style, Converter={StaticResource styleConv}}"
              TextBlock.FontWeight="{Binding Path=Font.Style, Converter={StaticResource weightConv}}"
                >
            <ctrls:CheckBoxFieldControl Checked="{Binding Checked}" UseAllWidth="{Binding UseAllWidth}"
                                        Editable="{Binding Editable}" ReadOnly="{Binding ReadOnly}"
                                        Label="{Binding Label}"
                                         BorderBrush="SteelBlue" x:Name="border"
                                        Focusable="{Binding Focusable}" Background="Transparent"
                                        />
        </Border>
        
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate DataType="{x:Type m:RadioButtonField}">
        <Border HorizontalAlignment="{Binding Path=HorizontalAlignment, Converter={StaticResource hconv}}"
              VerticalAlignment="{Binding Path=VerticalAlignment, Converter={StaticResource vconv}}"
              Background="{Binding Background, Converter={StaticResource bgConv}}" MinWidth="3" MinHeight="3"
               Margin="{Binding Margin}"
                TextBlock.FontSize="{Binding Path=Font, Converter={StaticResource sizeConv}}"
              TextBlock.FontStyle="{Binding Path=Font.Style, Converter={StaticResource styleConv}}"
              TextBlock.FontWeight="{Binding Path=Font.Style, Converter={StaticResource weightConv}}"
                >
            <ctrls:RadioFieldControl Checked="{Binding Selected}" UseAllWidth="{Binding UseAllWidth}"
                                        Editable="{Binding Editable}" ReadOnly="{Binding ReadOnly}"
                                        Label="{Binding Label}" Focusable="{Binding Focusable}"
                                     BorderBrush="SteelBlue" x:Name="border" Background="Transparent"
                                        />
        </Border>
        
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate DataType="{x:Type m:BitmapField}">
        <Border  HorizontalAlignment="{Binding Path=HorizontalAlignment, Converter={StaticResource hconv}}"
              VerticalAlignment="{Binding Path=VerticalAlignment, Converter={StaticResource vconv}}"
              Background="{Binding Background, Converter={StaticResource bgConv}}" MinWidth="3" MinHeight="3"
                 Margin="{Binding Margin}"
                 >
            <ctrls:BitmapFieldControl Bitmap="{Binding Bitmap}"
                                      VerticalSpace="{Binding VerticalSpace}" HorizontalSpace="{Binding HorizontalSpace}"
                                      BorderBrush="SteelBlue" x:Name="border" Background="Transparent"
                                      />
        </Border>
        
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate DataType="{x:Type m:GaugeField}">
        <Grid HorizontalAlignment="{Binding Path=HorizontalAlignment, Converter={StaticResource hconv}}"
              VerticalAlignment="{Binding Path=VerticalAlignment, Converter={StaticResource vconv}}"
              Background="{Binding Background, Converter={StaticResource bgConv}}" MinWidth="3" MinHeight="3"
              Margin="{Binding Margin}"
              TextBlock.FontSize="{Binding Path=Font, Converter={StaticResource sizeConv}}"
              TextBlock.FontStyle="{Binding Path=Font.Style, Converter={StaticResource styleConv}}"
              TextBlock.FontWeight="{Binding Path=Font.Style, Converter={StaticResource weightConv}}"
              >
            <ctrls:GaugeFieldControl Minimum="{Binding Minimum}" Maximum="{Binding Maximum}"
                                     Value="{Binding Value}" NoText="{Binding NoText}"
                                     LabelAsProgress="{Binding LabelAsProgress}" Percent="{Binding Percent}"
                                     Label="{Binding Label}" PercentValue="{Binding PercentValue}"
                                     HorizontalAlignment="Stretch"
                                     BorderBrush="SteelBlue" x:Name="border" 
                                     Background="Transparent"
                                     />

        </Grid>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
    <!--manager styles-->
    <DataTemplate DataType="{x:Type m:HorizontalFieldManager}">
        <Border BorderBrush="SteelBlue" x:Name="border"
                          HorizontalAlignment="{Binding Path=HorizontalAlignment, Converter={StaticResource hconv}}"
              VerticalAlignment="{Binding Path=VerticalAlignment, Converter={StaticResource vconv}}"
              Background="{Binding Path=Background, Converter={StaticResource bgConv}}" MinWidth="3" MinHeight="3"
                Margin="{Binding Margin}"
                TextBlock.FontSize="{Binding Path=Font, Converter={StaticResource sizeConv}}"
              TextBlock.FontStyle="{Binding Path=Font.Style, Converter={StaticResource styleConv}}"
              TextBlock.FontWeight="{Binding Path=Font.Style, Converter={StaticResource weightConv}}"
                >
            <ItemsControl ItemsSource="{Binding Fields}"
                           Background="Transparent"
                           MinWidth="3" MinHeight="3"
                          >
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <ctrls:HorizontalManager ClipToBounds="True"
                                                 UseAllHeight="{Binding UseAllHeight}" UseAllWidth="{Binding UseAllWidth}"
                                               VerticalScroll="{Binding VerticalScroll}" HorizontalScroll="{Binding HorizontalScroll}"
                                                 />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </Border>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
    
    <DataTemplate DataType="{x:Type m:VerticalFieldManager}">
        <Border BorderBrush="SteelBlue" x:Name="border"
                          HorizontalAlignment="{Binding Path=HorizontalAlignment, Converter={StaticResource hconv}}"
              VerticalAlignment="{Binding Path=VerticalAlignment, Converter={StaticResource vconv}}"
              Background="{Binding Path=Background, Converter={StaticResource bgConv}}" MinWidth="3" MinHeight="3"
                Margin="{Binding Margin}"
                TextBlock.FontSize="{Binding Path=Font, Converter={StaticResource sizeConv}}"
              TextBlock.FontStyle="{Binding Path=Font.Style, Converter={StaticResource styleConv}}"
              TextBlock.FontWeight="{Binding Path=Font.Style, Converter={StaticResource weightConv}}"
                >
            <ItemsControl ItemsSource="{Binding Fields}"
                           Background="Transparent"
                           MinWidth="3" MinHeight="3"
                          >
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <ctrls:VerticalManager ClipToBounds="True"
                                               UseAllHeight="{Binding UseAllHeight}" UseAllWidth="{Binding UseAllWidth}"
                                               VerticalScroll="{Binding VerticalScroll}" HorizontalScroll="{Binding HorizontalScroll}"
                                               />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                
            </ItemsControl>
        </Border>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
    
    <DataTemplate DataType="{x:Type m:FlowFieldManager}">
        <Border BorderBrush="SteelBlue" x:Name="border" 
               HorizontalAlignment="{Binding Path=HorizontalAlignment, Converter={StaticResource hconv}}"
              VerticalAlignment="{Binding Path=VerticalAlignment, Converter={StaticResource vconv}}"
              Background="{Binding Path=Background, Converter={StaticResource bgConv}}"
                Margin="{Binding Margin}"
                TextBlock.FontSize="{Binding Path=Font, Converter={StaticResource sizeConv}}"
              TextBlock.FontStyle="{Binding Path=Font.Style, Converter={StaticResource styleConv}}"
              TextBlock.FontWeight="{Binding Path=Font.Style, Converter={StaticResource weightConv}}"
                >
            <ItemsControl ItemsSource="{Binding Fields}" Background="Transparent" MinWidth="3" MinHeight="3">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <ctrls:WrapManager UseAllHeight="{Binding UseAllHeight}" UseAllWidth="{Binding UseAllWidth}"
                                               VerticalScroll="{Binding VerticalScroll}" HorizontalScroll="{Binding HorizontalScroll}"
                                        ClipToBounds="True"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </Border>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate DataType="{x:Type ms:MainScreen}">
        <Border Background="{Binding Path=Background, Converter={StaticResource bgConv}}"
                BorderBrush="SteelBlue" x:Name="border"
                TextBlock.FontSize="{Binding Path=Font, Converter={StaticResource sizeConv}}"
              TextBlock.FontStyle="{Binding Path=Font.Style, Converter={StaticResource styleConv}}"
              TextBlock.FontWeight="{Binding Path=Font.Style, Converter={StaticResource weightConv}}"
                >
            <ItemsControl ItemsSource="{Binding Fields}" Background="Transparent">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <ctrls:VerticalManager UseAllWidth="True" UseAllHeight="True"
                                                   VerticalScroll="{Binding VerticalScroll}"
                                                   HorizontalScroll="{Binding HorizontalScroll}"
                                                   ClipToBounds="True">
                        </ctrls:VerticalManager>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </Border>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected}" Value="True">
                <Setter Property="BorderThickness" Value="2" TargetName="border"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>


</ResourceDictionary>